﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LPY.LeHealth.DTO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;


namespace LPY.LeHealth.DAL
{
    using ServiceStack.OrmLite;
    
     public  class ClassifyTypeDAL:BaseDAL
    {
         string constring = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
         /// <summary>
         /// 查询体检范围分类表
         /// </summary>
         /// <returns></returns>
         public List<ClassifyType> GetClassifytype()
         { 
            using(var conn=DbConnection)
            {
                var sql = conn.From<ClassifyType>();
                return conn.Select(sql);
            }
         }
         /// <summary>
         /// 查询体检项表分类
         /// </summary>
         /// <param name="Tid"></param>
         /// <returns></returns>
         public List<Classify> GetClassify(int Tid)
         { 
            using (var conn=DbConnection)
            {
                var sql = conn.From<Classify>()
                    .Where(m=>m.Tid==Tid);
                return conn.Select(sql);
            }
         }
         /// <summary>
         /// 添加提问数据
         /// </summary>
         /// <param name="q"></param>
         /// <returns></returns>
         public int QueAdd(questions q)
         {
             string str = "insert into t_questions(content,Qage,Qsex,Qphone,Qstate,Uid,Qdate,Tid,ttid,Qhits) values('"+q.content+"','"+q.Qage+"','"+q.Qsex+"','"+q.Qphone+"','"+q.Qstate+"','"+q.Uid+"','"+q.Qdate+"','"+q.Tid+"','"+q.ttid+"','5')";
             SqlConnection conn = new SqlConnection(constring);
             conn.Open();
             SqlCommand comm = new SqlCommand(str,conn);
             return comm.ExecNonQuery();
         }
         /// <summary>
         /// 添加回复表
         /// </summary>
         /// <param name="r"></param>
         /// <returns></returns>
         public int AddReplyd(ReplyDTO r)
         {

             string str = "insert into t_replydto(Qid,Rcontent,Rdate,Pname) values(" + r.Qid + ",'" + r.Rcontent + "','" + r.Rdate + "','" + r.Pname + "')";
             SqlConnection conn = new SqlConnection(constring);
             conn.Open();
             SqlCommand comm = new SqlCommand(str, conn);
             return comm.ExecNonQuery();
         }

         
    }
}
